<?php
  /**
   * @author claudiugh
   */

class PT_Line
{
  var $name;
  var $stations_hash;
  var $arcs;

  /**
   *
   */
  function PT_Line($name)
  {
    $this->name = $name; 
    $this->stations_hash = array();
    $this->arcs = array();
  }

  function add_station($name, $location)
  {
    if (array_key_exists($name, $this->stations_hash))
      die("Station $name already exists");
    $this->stations_hash[$name] = $location;
  }

  function add_stations($stations)
  {
    $this->stations_hash = array_merge($this->stations_hash, $stations);
  }

  function add_arc($arc)
  {
    if (!array_key_exists($arc->from, $this->stations_hash))
      die("Invalid source: $arc->from ");
    
    if(!array_key_exists($arc->to, $this->stations_hash))
      die("Invalid destionation: $arc->to ");          
    array_push($this->arcs, $arc);
  }

  function add_arcs($arcs)
  {
    foreach ($arcs as $arc)
      $this->add_arc($arc);
  }
  
}

?>